<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui"
                xmlns:h="http://java.sun.com/jsf/html" xmlns:util="http://xmlns.jcp.org/jsf/composite/util">

    <h:form id="contracts_form">
        <util:dataTableWrapper title="Lista contracte">
            <f:facet name="buttonContent">
                <p:commandButton icon="custom-icon-add" value="Adauga contract nou"
                                 oncomplete="PF('add_contract_WV').show()" update=":create_contract_form"
                                 resetValues="true"
                                 actionListener="#{employmentDataBean.resetCreateContractDialog}"/>
            </f:facet>

            <p:dataTable id="contracts_table" var="c" value="#{employmentDataBean.contracts}"
                         emptyMessage="Nu a fost gasita nici o inregistrare.">

                <p:column headerText="Principal" width="5%">
                    <h:outputText value="#{c.basic}"/>
                </p:column>

                <p:column headerText="Numar contract" width="20%">
                    <h:outputText value="#{c.contractNr}"/>
                </p:column>

                <p:column headerText="Data contract" width="10%">
                    <h:outputText value="#{c.contractDate}">
                        <f:convertDateTime pattern="dd/MM/yyyy"/>
                    </h:outputText>
                </p:column>

                <p:column headerText="Valabil din" width="10%">
                    <h:outputText value="#{c.fromDate}">
                        <f:convertDateTime pattern="dd/MM/yyyy"/>
                    </h:outputText>
                </p:column>

                <p:column headerText="Valabil pana la" width="10%">
                    <h:outputText value="#{c.toDate}">
                        <f:convertDateTime pattern="dd/MM/yyyy"/>
                    </h:outputText>
                </p:column>

                <p:column headerText="Termen proba" width="20%">
                    <h:outputText value="#{c.trialPeriod}"/>
                </p:column>

                <p:column styleClass="override-icons" headerText="Actions">
                    <p:commandButton icon="custom-icon-edit"
                                     actionListener="#{employmentDataBean.setSelectedContract(c)}"
                                     oncomplete="PF('add_contract_WV').show()" update=":create_contract_form"/>

                    <p:commandButton icon="custom-icon-delete"
                                     actionListener="#{employmentDataBean.deleteContract(c)}"
                                     update="@form">
                        <p:confirm header="Confirma"
                                   message="Sunteti sigur ca doriti stergerea contractului selectat?"
                                   icon="ui-icon-alert"/>
                    </p:commandButton>

                    <p:commandButton icon="custom-icon-view" value="Acorduri"
                                     update=":contract_agreements_form"
                                     actionListener="#{employmentDataBean.setSelectedContract(c)}"
                                     process="@this" onclick="PF('contract_agrs_WV').show();"/>
                </p:column>
            </p:dataTable>
        </util:dataTableWrapper>
        <p:confirmDialog global="true">
            <p:commandButton value="Da" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check"/>
            <p:commandButton value="Nu" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>
        </p:confirmDialog>
    </h:form>

    <h:form id="work_experiences_form">

        <util:dataTableWrapper title="Lista experinta de lucru">
            <f:facet name="buttonContent">
                <p:commandButton icon="custom-icon-add" value="Adauga experienta de lucru"
                                 oncomplete="PF('add_work_experience_WV').show()"
                                 update=":create_work_experience_form"
                                 resetValues="true"
                                 actionListener="#{employmentDataBean.resetCreateWorkExperienceDialog}"/>
            </f:facet>
            <p:dataTable id="work_experiences_table" var="we" value="#{employmentDataBean.workExperiences}"
                         emptyMessage="Nu a fost gasita nici o inregistrare.">

                <p:column headerText="Locul de munca">
                    <h:outputText value="#{we.workPlace}"/>
                </p:column>

                <p:column headerText="Functia">
                    <h:outputText value="#{we.position}"/>
                </p:column>

                <p:column headerText="Inceput activitate">
                    <h:outputText value="#{we.fromDate}">
                        <f:convertDateTime pattern="dd/MM/yyyy"/>
                    </h:outputText>
                </p:column>

                <p:column headerText="Sfarsit activitate">
                    <h:outputText value="#{we.toDate}">
                        <f:convertDateTime pattern="dd/MM/yyyy"/>
                    </h:outputText>
                </p:column>

                <p:column headerText="Categorie">
                    <h:outputText value="#{we.workType.name}"/>
                </p:column>

                <p:column styleClass="override-icons" headerText="Actions">
                    <p:commandButton icon="custom-icon-edit" value="Editeaza"
                                     actionListener="#{employmentDataBean.initEditWorkExperienceDialog(we)}"
                                     oncomplete="PF('add_work_experience_WV').show()"
                                     update=":create_work_experience_form"/>

                    <p:commandButton icon="custom-icon-delete" value="Sterge"
                                     actionListener="#{employmentDataBean.deleteWorkExperience(we)}"
                                     update="@form">
                        <p:confirm header="Confirma"
                                   message="Sunteti sigur ca doriti stergerea experientei de munca selectata?"
                                   icon="ui-icon-alert"/>
                    </p:commandButton>
                </p:column>
            </p:dataTable>
        </util:dataTableWrapper>
        <p:confirmDialog global="true">
            <p:commandButton value="Da" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check"/>
            <p:commandButton value="Nu" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>
        </p:confirmDialog>
    </h:form>
</ui:composition>